/*
 * Created on 2006-8-8
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package other;

import java.util.Iterator;
import java.util.Map;

import com.powerunion.datacollection.report.excelreport.ReportEntry;
import com.powerunion.datacollection.report.excelreport.config.ReportConfig;
import com.powerunion.datacollection.report.excelreport.datasource.CommonDBDataSource;
import com.powerunion.datacollection.report.excelreport.datasource.StaticDataSource;


/**
 * @author juny
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class StudentGradeDemo extends ReportEntry {
    public boolean execute(
            ReportConfig reportConfig, //报表配置参数对象
            Map dataSources, 		   //报表数据源
            Map params				   //传入参数。
            )throws Exception{   
        StaticDataSource ds = (StaticDataSource)dataSources.get("ds");
    	//CommonDBDataSource ds = (CommonDBDataSource)dataSources.get("ds");
    	
        if(null != ds){  
//        	ds.query(params);
//        
//        	for(Iterator iter = ds.iterator();iter.hasNext();){
//        		Map map = (Map)iter.next();
//	            ds.addField("id", map.get("USER_CODE"));
//	            ds.addField("name", map.get("USER_CODE"));
//	            ds.addField("chinese", map.get("FULL_NAME"));
//	            ds.addField("math", map.get("SMS_FLAGEX"));
//	            ds.addField("english", map.get("MAIL_FLAGEX"));
//	            ds.addField("politics",  map.get("MAIL_FLAGEX"));
//	            ds.addField("history", map.get("USER_PWD"));
//	            ds.addField("geography", map.get("USER_PWD"));
//	            ds.addField("biology", map.get("USER_PWD"));
//	            ds.addRecord();
//        	}
     
       
        	
	        String state = (String)params.get("arg1");
	        int number = Integer.parseInt(state);
	        int radom1 = 0;
	        for(int i=0; i<number; i++){
	            ds.addField("id", "2006"+i);
	            ds.addField("name", "王*"+i);
	            radom1 = (int)Math.abs(Math.random()*100);
	            ds.addField("chinese", new Integer(radom1));
	            radom1 = (int)Math.abs(Math.random()*100);
	            ds.addField("math", new Integer(radom1));
	            radom1 = (int)Math.abs(Math.random()*100);
	            ds.addField("english", new Integer(radom1));
	            radom1 = (int)Math.abs(Math.random()*100);
	            ds.addField("politics", new Integer(radom1));
	            radom1 = (int)Math.abs(Math.random()*100);
	            ds.addField("history", new Integer(radom1));
	            radom1 = (int)Math.abs(Math.random()*100);
	            ds.addField("geography", new Integer(radom1));
	            radom1 = (int)Math.abs(Math.random()*100);
	            ds.addField("biology", new Integer(radom1));
	            ds.addRecord();
	        }
        }
        return true;
    }

}
